﻿// <copyright file="QldStateResultsByElectorate2006FileDefinitionTest.cs" company="QUT">
//     Copyright (c) Ninety Nine Percent. All rights reserved.
// </copyright>

namespace Qut.GenerateKml.Data
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using FileHelpers.DataLink;
    using NUnit.Framework;

    /// <summary>
    /// A class for QldStateResultsByElectorate2006FileDefinition class.
    /// </summary>
    [TestFixture]

    public class QldStateResultsByElectorate2006FileDefinitionTest
    {
        /// <summary>
        /// SociologicalData sociological
        /// </summary>
        private SociologicalData sociological;

        /// <summary>
        /// Initializes the all data member in the test.
        /// </summary>
        [SetUp]
        public void Initialize()
        {
            this.sociological = new SociologicalData();
        }

        /// <summary>
        /// Test load(): Count rows
        /// </summary>
        [Test]
        public void Load_Count()
        {
            this.sociological.PreloadQldStateResultsByElectorate2006("Qld_State Results by Electorate-2006.xls");
            var results = from r in this.sociological.Database.QldStateResultsByElectorate2006s
                          select r;
            Assert.AreEqual(87, results.Count());
        }

        /// <summary>
        /// Test load(): first and last element in database
        /// </summary>
        [Test]
        public void Load_FirstLastElement()
        {
            this.sociological.PreloadQldStateResultsByElectorate2006("Qld_State Results by Electorate-2006.xls");
            var results = from r in this.sociological.Database.QldStateResultsByElectorate2006s
                          select r;

            string firstDistrictName = string.Empty;

            foreach (var result in results)
            {
                firstDistrictName = result.DistrictName;
                break;
            }

            Assert.AreEqual(firstDistrictName, "Albert");

            string lastDistrictName = string.Empty;
            foreach (var result in results)
            {
                lastDistrictName = result.DistrictName;
            }

            Assert.AreEqual(lastDistrictName, "Yeerongpilly");
        }
    }
}

